home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / SiFLyiNG_5.txt < prev    next >
Encoding:
Text File  |  1999-07-26  |  6.7 KB  |  177 lines

  1.  
  2.  
  3.         SiFLyiNG
  4.                 Tutorial #5
  5.  
  6. ____________________________________________________________________________
  7.  
  8. Target          : AfKayAs CrackMe #1
  9.                   d/l it on EB site http://crackmes.cjb.net
  10. Protection type : Serial/Name, VB
  11. Tools needed    : SoftIce, Windasm, Basis of VB cracking & functions
  12. ____________________________________________________________________________
  13.  
  14. Before beginning...
  15.  
  16.         This crackme is based on a simply serial/name protection. The serial
  17. is calculated with your name and the routine is not very difficult. First
  18. we'll see how to find a serial in a minute and then we'll see the routine
  19. wich calculates the serial from your name, so that you'll be able to code
  20. your own keygen. Time is money, so let's start !
  21.  
  22. ____________________________________________________________________________
  23.  
  24. The essay...
  25.  
  26.         1. The serial
  27.  
  28.         If you disassemble this crackme with Windasm, you'll see that it's coded
  29. with VB5. Look in the imports to find an entry point in the code. You
  30. should find interested functions like : __vbaStrCmp, __vbaLenBstr (returns the
  31. len of a string) or rtcMsgBox (displays a message in a dialog box).
  32.         So, we could try the classic comparison call: __VbStrCmp, which would be
  33. the best way (i think) to find a valid serial. Let's enter a name: 'SiFLyiNG'
  34. and a serial :'12345678'. Press the 'OK' button and you're back in SoftIce:
  35.  
  36.                 'Break due to BPX MSVBVM50!__vbaStrCmp'
  37.  
  38.         Return to the caller with F11 and you should see:
  39.  
  40. :402533 Call [MSVBVM50!__vbaStrCmp]
  41. :402539 MOV ESI, EAX
  42.  
  43.         Eax contains what the comparison function has returned when comparing
  44. the valid code and our code. In our case Eax = FFFF FFFF but when our code
  45. is the valid code, it returns Eax = 0000 0000. That will be useful for the
  46. jz Good Guy at line 40258B which will jump if Eax = 0, ie if the both code
  47. (ours and the valid generated by the crackme) are the same. But in our case
  48. it'll return FFFFFFFF so they'll be no jump and a MessageBox : 'You get wrong'
  49.         But the aim of the crackme is not to patch but to find a valid serial.
  50. So, we're back to the comparison : if you trace up a bit you'll see :
  51.  
  52. :402532 Push Eax
  53. :402533 Call [MSVBVM50!__vbaStrCmp]
  54. :402539 MOV ESI, EAX
  55.  
  56.         Thus, we can suppose that Eax contains the adress where the valid code
  57. is stored. Let's try ! BPX on this line : either double click on it, or
  58. 'bpx 402532'. Back to Win. Press ok : the line is highlighted. Let's try a
  59. 'd eax'. Hummm, we see : AKA-780331. I bet it's the valid serial ;)
  60.         Disable your breakpoints and exit SoftIce. Enter the string, press
  61. the 'OK' button : 'You get it. Keygen it now.'
  62.  
  63.         Ok, the crackme is cracked. But we won't stop there ! Let's keygen it,
  64. as the author, AfKayAs asked.
  65.  
  66.         2. The keygen
  67.  
  68.         To find the calculation routine, we'll try to enter in the code with
  69. SoftIce in a different way. Logically, the calculation routine is  up
  70. to the comparison routine, so we'll see with WinDasm where we could break to
  71. find this routine. If you place yourself on the adress 402532 and you trace up,
  72. you will see call to VB functions like:
  73.  
  74. - MSVBVM50.__vbaStrMove
  75. - MSVBVM50.__vbaStrCat
  76. - MSVBVM50.__vbaHresultCheckObj
  77.  
  78. ...not very attractive... but if you trace up until 0040242D you'll see some
  79. very interesting calls :
  80.  
  81. - MSVBVM50.__vbaLenBstr : returns the lenght of a string, and probably the lenght
  82.                         of the entered name here )
  83. - MSVBVM50.rtcAnsiValueBstr : i believe it returns the ascii value of a char
  84.                         ( when it's used with a string, it always returns the
  85.                         ascii code of the first char of the string)
  86.  
  87. So, we could make a bpx on __vbaLenBstr in SoftIce. Press F11 and you arrive
  88. here :
  89.  
  90. * Reference To: MSVBVM50.__vbaLenBstr, Ord:0000h
  91.                                   |
  92. :00402415 Call dword ptr [004040E4]  ;call to __vbaLenBstr
  93. :0040241B mov edi, eax ; the call returns the len of the name in eax
  94.                        ; so eax = 8 for 'SiFLyiNG' and edi = 8 too
  95. :0040241D mov ecx, dword ptr [ebp-18] ; 'd ecx' and you'll see the name
  96. :00402420 imul edi, 00017CFB ; edi = len * 17CFBh (h for hexa)
  97. :00402426 push ecx  ; push the name on the stack (in wide characters)
  98. :00402427 jo 004026BE ; jump in case of overflow
  99.  
  100. * Reference To: MSVBVM50.rtcAnsiValueBstr, Ord:0204h
  101.                                   |
  102. :0040242D Call dword ptr [004040F8] ; call to rtcAnsiValueBstr
  103.  
  104. ( the call returns the ascii code of the first char of the string the last
  105. pushed on the stack, wich here is the name, so it will return the ascii code
  106. the first char of our name in eax, here the code for 'S', 53h)
  107.  
  108. :00402433 movsx edx, ax ; ax = 53h so edx = 0000 0053h
  109. :00402436 add edi, edx ; add edx to edi
  110. :00402438 jo 004026BE ; jump if overflow
  111. :0040243E push edi    ; save edi
  112.  
  113.         But what does EDI contains ? Do '? EDI' and you'll see :
  114.  
  115.         EDI = BE82Bh = 780331
  116.  
  117.         Doesn't it remind you something ? Yes the code previously found was :
  118. 'AKA-780331'. Now you should understand. So, this little routine has
  119. calculated the second part of the keygen. Then, this part will be converted
  120. from hexadecimal to decimal, then converted to a string and finally added to
  121. the string 'AKA-'. Now we know what's necessary to make a keygen.
  122.  
  123.         Let's summarize :
  124.  
  125. 1. it takesthe lenght of the name
  126. 2. the len is multiplied with the value 17CFBh
  127. 3. the ascii code of the first char of the name is added to the previous value
  128.    calculated in 2.
  129. 4. the value is converted to decimal
  130. 5. the second part is converted to a string and added to 'AKA-'
  131.  
  132.         but we could make easier, directly in decimal base :
  133.  
  134. 1. second_part=len_of_name * 97531 + ascii_code_of_the_first_char_of_the_name
  135. 2. serial = 'AKA-' & second_part
  136.  
  137.         so in QBasic it will make :
  138.  
  139. INPUT "Name: "; username$
  140. serial$ = "AKA-" + RTRIM$(LTRIM$(STR$(LEN(username$) * 97531 + ASC(username$))))
  141. PRINT serial$
  142.  
  143.         and in VB :
  144.  
  145. Serial = "AKA-" & Trim(Str(Len(username) * &H17CFB + Asc(username)))
  146.  
  147.         Of course you can make it with ASM, C++ and whatever you want !!!
  148.  
  149. ____________________________________________________________________________
  150.  
  151. The end...
  152.  
  153.         Voila, another crackme cracked and 'keygened'. I've tried to make it
  154. sufficiently understandable but if you have a problem, or if i made an error,
  155. a nonsense... just mail me. 
  156.  
  157.                 SiFLyiNG
  158.                         siflying@ifrance.com
  159.  
  160.         Greetz : Eternal Bliss, Acid Burn, Lucifer48, Carpathia, Skymarshall,
  161.                 and all the others that i don't know ...
  162.  
  163.  
  164.  
  165.  
  166.  
  167.                                 
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.                 
  177.